#include "stdafx.h"
#include "QToolMenu_p.h"

QLabelEx::QLabelEx( QWidget* parent /*= 0*/ )
	:QLabel(parent)
{
	setSizePolicy(QSizePolicy::Preferred ,QSizePolicy::Expanding);
	setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

	m_pLine = NULL;
	m_pAttachWidget = NULL;
	m_nIndexWidget = -1;

}

QLabelEx::~QLabelEx()
{

}

void QLabelEx::showLabel( bool bShow )
{
	if(bShow)
	{
		show();
		if(m_pLine)  m_pLine->show();
	}
	else
	{
		hide();
		if(m_pLine)  m_pLine->hide();
	}

	m_bShow = bShow;
}

bool QLabelEx::isShowLabel()
{
	return  m_bShow;
}

void QLabelEx::enterEvent( QEvent* e )
{
	setCursor(Qt::PointingHandCursor);
}

void QLabelEx::leaveEvent( QEvent* e )
{
	setCursor(Qt::ArrowCursor);
}

void QLabelEx::mousePressEvent( QMouseEvent *event )
{
	if(m_pAttachWidget)
		emit  onOpenTabWidgetSignal(m_pAttachWidget);
	if(m_nIndexWidget > 0)
		emit  onOpenTabIndexSignal(m_nIndexWidget);
	
	QLabel::mousePressEvent(event);
}

void QLabelEx::mouseDoubleClickEvent( QMouseEvent *event )
{
	QLabel::mouseDoubleClickEvent(event);
}

//void QLabelEx::mouseMoveEvent( QMouseEvent *event )
//{
//
//	QLabel::mouseMoveEvent(event);
//}
